package com.citcc.api.controller;

import com.citcc.api.netty.server.ChannelMap;

import com.citcc.framework.base.BaseController;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;



import javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: 李亚冲
 * Date: 2019/5/9
 * Time: 10:20
 * Description: 扫码充电相关接口
 */
@Api(tags = "终端在线数")
@RestController
public class OnlineController extends BaseController{
    private Logger logger = LoggerFactory.getLogger(OnlineController.class);
    
    @RequestMapping(value = "/v2/online", method = RequestMethod.POST)
    public Object online(HttpServletRequest request) {
    	if(ChannelMap.channelHashMap!=null){
    		return success(200, ChannelMap.getNum());
    	}else{
    		return success(200, 0);
    	}
    	
    }
    /**
     * 功能描述: 在线的终端号
     * @auther: lsfts
     * @date: 2019/5/10 17:43
     */
    @RequestMapping(value = "/v2/onlineStake", method = RequestMethod.POST)
    public Object onlineStake() {
    	if(ChannelMap.channelHashMap!=null){
			Set<String> list = ChannelMap.channelHashMap.keySet();
			return success(200, list);
    	}else{
    		return success(200, null);
    	}
    }

}